//
//  UserListPresenter.swift
//  demo
//
//  Created by 刘洪宝 on 2025/2/9.
//

class UserListPresenter: UserListPresenterProtocol, UserListInteractorOutputProtocol {
    weak var view: UserListViewProtocol?
    var interactor: UserListInteractorProtocol?
    var router: UserListRouterProtocol?
    
    func viewDidLoad() {
        view?.showLoading()
        interactor?.fetchUsers()
    }
    
    func didSelectUser(_ user: User) {
        router?.navigateToUserDetail(from: view, user: user)
    }
    
    // MARK: - UserListInteractorOutputProtocol
    func usersFetched(_ users: [User]) {
        view?.hideLoading()
        view?.showUsers(users)
    }
    
    func usersFetchFailed(_ error: Error) {
        view?.hideLoading()
        view?.showError(error.localizedDescription)
    }
} 
